<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>VEadmin-登录</title>
    <link rel="shortcut icon" href="/static/weadmin/favicon_white.ico">
    <link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="/static/weadmin/css/login.css">
</head>
<body>
<div id="particles"></div>
<div class="centent">
    <div class="centent-header">
        <h1 class="header-title hide">为懿</h1>
        <h2 class="header-sub-title">永远相信 - 美好的事情即将发生</h2>
    </div>

    <div class="centent-main clearfix">
        <div class="slide-tab">
            <div class="slide-tab-nav">
                <a href="login.html" class="active">登录</a>
                <a href="#">注册</a>
                <div class="slide-bar"></div>
            </div>
        </div>
        <div class="form-login">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="text" name="username" id="username" placeholder="账号（支持手机号/邮箱/账户名）"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="password" name="password" placeholder="密码（六位及以上）"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                {{if config('verify')==true}}
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input type="verify" name="verify" placeholder="验证码"
                                   autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux"><img src="{{:url('admin/login/verify')}}" class="imgcode" id="verify-image"></div>
                    </div>
                {{/if}}
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formLogin">登录</button>
                    </div>
                </div>
                <div class="remember clearfix">
                    <input type="checkbox" name="me" title="记住我" lay-skin="primary" checked>
                    <label class="forgot-password">
                        <a href="#">忘记密码？</a>
                    </label>
                </div>
            </form>

            <script src="/static/layui/layui.js" type="text/javascript"></script>
            <script>
                layui.use(['form','layer','jquery'], function () {
                    var form = layui.form;
                    layer = layui.layer;
                    $ = jquery = layui.jquery;

                    $('#verify-image').click(function() {
                        $(this).attr('src',"{{:url('admin/login/verify')}}");
                    });

                    form.on('submit(formLogin)', function (data) {
                        // layer.msg(JSON.stringify(data.field));
                        if(data.field.username === ""){
                            layer.msg("请填写账号");
                            return false;
                        }
                        if(data.field.password === ""){
                            layer.msg("请填写密码");
                            return false;
                        }
                        $.post("/admin/login/login", data.field, function (result) {
                            if(result.code === 200){
                                window.location.reload();
                            }
                            if(result.code === 500){
                                layer.msg('失败啊');
                                return false;
                            }
                            if(result.code === 999){
                                layer.msg('验证码不正确');
                                return false;
                            }
                        });
                    });
                });
            </script>
        </div>
    </div>
</div>
<div class="footer">
    <p>为懿（VEadmin） - 全面开源 快速开发管理平台</p>
    <p>powered by haigle & <a href="http://weibo.haigle.cn" target=_blank>不是龙王的如意金箍棒</a> &copy 2013-2018</p>
</div>
<script src='/static/weadmin/js/plugins/particles/particles.js' type="text/javascript"></script>
<script src='/static/weadmin/js/plugins/particles/particles-json.js' type="text/javascript"></script>
</body>
</html>